import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../AppConfig/Config.dart';
import '../../l10n/messages.dart';

class BankCardWithdrawal extends StatefulWidget {
  const BankCardWithdrawal({super.key});

  @override
  State<BankCardWithdrawal> createState() => _BankCardWithdrawalState();
}

class _BankCardWithdrawalState extends State<BankCardWithdrawal> {
  List cardList=["中国银行储蓄卡(1234)","中国建设银行储蓄卡(1234)"];
  int cardNum=-1;
  @override
  Widget build(BuildContext context) {
    var messages = AppLocalizations.of(context)!;
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        backgroundColor: Colors.white,
        centerTitle: true,
        leading: IconButton(
          icon: Icon(Icons.arrow_back_ios, color: Colors.black),
          onPressed: () => Navigator.of(context).pop(),
        ),
        title: Text(messages['提现'],style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp),),
      ),
      body: ListView(
        children: [
          GestureDetector(
            child:  Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(10)),
                color: Colors.white,
              ),
              margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
              padding: EdgeInsets.only(top:10.h,bottom: 10.h,left: 18.w,right: 18.w),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text("到账银行卡",style: TextStyle(color: Colors.black,),),
                  SizedBox(height: 8.h,),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Row(
                        children: [
                          cardNum ==-1?
                      Image.asset("lib/Images/PersonCenter/选择到账银行卡icon.png",width: 22.w,height: 22.h,)
                        :Image.asset("lib/Images/PersonCenter/中国银行icon.png",width: 24.w,height: 24.h,),
                      SizedBox(width: 8.w,),
                          cardNum==-1?
                          Text("添加到账储蓄卡提现",style: TextStyle(color: MyColors.textColor),)
                          :Text(cardList[cardNum],style: TextStyle(color: Colors.black),),
                        ],
                      ),
                      Icon(Icons.arrow_forward_ios,color: MyColors.textColor,),
                    ],
                  ),

                ],
              ),
            ),
            onTap: () {
              showModalBottomSheet(
                context: context, builder: (BuildContext context) {
                return Container(
                  height: 240.h,
                  padding: EdgeInsets.only(top: 10.h,bottom: 20.h,right: 8.w,left: 8.w),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(10)),
                    color: Color.fromRGBO(245, 245, 249, 1),
                  ),

                  child: Column(
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          SizedBox(),

                          Text("选择到账银行卡",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),

                         GestureDetector(
                           child: Icon(Icons.close,size: 30,color: MyColors.textColor,),
                           onTap: (){
                             Navigator.pop(context);
                           },
                         ),
                        ],
                      ),
                      SizedBox(height: 8.h,),
                      Container(
                        padding: EdgeInsets.only(right: 10.w,left: 10.w),
                        height: (cardList.length+1)*50.h,
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.all(Radius.circular(10)),
                          color: Colors.white,
                        ),
                        child:Column(
                          children: [
                            Container(
                              height: cardList.length*55.h,
                              child:   ListView.builder(

                                itemCount: cardList.length,
                                itemBuilder: (BuildContext context, int index) {
                                  return Column(
                                    children: [
                                      SizedBox(height: 10.w,),
                                      Row(
                                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                        crossAxisAlignment: CrossAxisAlignment.center,
                                        children: [
                                          Row(
                                          children: [
                                            Image.asset("lib/Images/PersonCenter/中国银行icon.png",width: 24.w,height: 24.h,),
                                            SizedBox(width: 10.w,),
                                            Text(cardList[index],style: TextStyle(color: Colors.black),),
                                          ],
                                          ),
                                        GestureDetector(
                                          child: cardNum==index?Icon(Icons.
                                          check_circle,color: MyColors.themeColor,) :Icon(Icons.panorama_fish_eye,color: MyColors.textColor,),
                                          onTap: (){
                                            setState(() {
                                              cardNum =index;
                                            });
                                            Navigator.pop(context);
                                          },
                                        ),
                                        ],
                                      ),
                                      SizedBox(height: 10.h,),
                                      Container(
                                        height: 1.h,
                                        color: MyColors.backgreyColor,
                                      ),
                                    ],
                                  );
                                },
                              ),
                            ),
                            GestureDetector(
                              child:  Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Row(
                                    children: [
                                      SizedBox(width: 8.w,),
                                      Image.asset("lib/Images/PersonCenter/选择到账银行卡icon.png",width: 22.w,height: 22.h,),
                                      SizedBox(width: 8.w,),
                                      Text("添加储蓄卡提现",style: TextStyle(color: Colors.black),),
                                    ],
                                  ),
                                  GestureDetector(
                                    child: Icon(Icons.arrow_forward_ios,color: MyColors.textColor,),
                                    onTap: (){

                                    },
                                  ),
                                ],
                              ),
                            ),

                          ],
                        ),

                      ),
                    ],
                  ),
                );


              },
              );
            }
          ),
          Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(10)),
              color: Colors.white,
            ),
            margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
            padding: EdgeInsets.only(top:10.h,bottom: 10.h,left: 18.w,right: 18.w),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text("提现金额",style: TextStyle(color: Colors.black),),
                SizedBox(height: 8.h,),
                Row(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    Text("¥",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                    Text("200.00",style: TextStyle(color: MyColors.themeColor,fontSize: 28.sp,fontWeight: FontWeight.w600),),
                  ],
                ),


              ],
            ),
    ),
          GestureDetector(
            child:   Container(
              height: 40.h,
              margin:EdgeInsets.only(top: 50.h,left: 15.w,right: 15.w) ,
              decoration: BoxDecoration(
                color:cardNum==-1? Color.fromRGBO(223, 223, 223, 1):MyColors.themeColor,
                borderRadius: BorderRadius.all(Radius.circular(30)),
              ),
              child: Center(
                child: Text("确认提现",style: TextStyle(color: Colors.white,fontSize: 16.sp,fontWeight: FontWeight.w600),),
              ),
            ),
            onTap: (){

            },
          ),
        ],
      ),
    );
  }
}
